home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / tpascal / vbdll / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-29  |  4.9 KB  |  140 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   4365
  5.    ClientLeft      =   1080
  6.    ClientTop       =   1485
  7.    ClientWidth     =   7335
  8.    Height          =   4770
  9.    Left            =   1020
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4365
  12.    ScaleWidth      =   7335
  13.    Top             =   1140
  14.    Width           =   7455
  15.    Begin CommandButton Command3 
  16.       Caption         =   "Call Min/Max Functions"
  17.       Height          =   495
  18.       Left            =   120
  19.       TabIndex        =   3
  20.       Top             =   3180
  21.       Width           =   2475
  22.    End
  23.    Begin CommandButton Command2 
  24.       Caption         =   "Call Array Function"
  25.       Height          =   495
  26.       Left            =   120
  27.       TabIndex        =   2
  28.       Top             =   2160
  29.       Width           =   2475
  30.    End
  31.    Begin CommandButton Command1 
  32.       Caption         =   "Call RTrim Function"
  33.       Height          =   495
  34.       Left            =   120
  35.       TabIndex        =   1
  36.       Top             =   1200
  37.       Width           =   2475
  38.    End
  39.    Begin CommandButton cmdTestPassword 
  40.       Caption         =   "Call GetPassword Function "
  41.       Height          =   495
  42.       Left            =   120
  43.       TabIndex        =   0
  44.       Top             =   120
  45.       Width           =   2475
  46.    End
  47.    Begin Label Label5 
  48.       Caption         =   "The code is in each button's click event.  Watch the debug window to see whats happening. "
  49.       ForeColor       =   &H00800000&
  50.       Height          =   435
  51.       Left            =   120
  52.       TabIndex        =   8
  53.       Top             =   3840
  54.       Width           =   6075
  55.    End
  56.    Begin Label Label4 
  57.       Caption         =   "Passes and returns integers."
  58.       Height          =   435
  59.       Left            =   2820
  60.       TabIndex        =   7
  61.       Top             =   3180
  62.       Width           =   4095
  63.    End
  64.    Begin Label Label3 
  65.       Caption         =   "Passes a user defined type array to the dll to be loaded with all files in the current directory.  This example passes fixed-length strings, which don't have a null-terminator at the end."
  66.       Height          =   855
  67.       Left            =   2820
  68.       TabIndex        =   6
  69.       Top             =   2100
  70.       Width           =   4095
  71.    End
  72.    Begin Label Label2 
  73.       Caption         =   "Passes a regular VB string 'Dim S as string' to the dll to be trimmed.  The function passes back a regular VB string."
  74.       Height          =   615
  75.       Left            =   2880
  76.       TabIndex        =   5
  77.       Top             =   1140
  78.       Width           =   4095
  79.    End
  80.    Begin Label Label1 
  81.       Caption         =   "Uses a Delphi form to get the password.  This example passes a null-terminated string."
  82.       Height          =   615
  83.       Left            =   2880
  84.       TabIndex        =   4
  85.       Top             =   120
  86.       Width           =   4155
  87.    End
  88. Option Explicit
  89. Declare Function GetPassword Lib "vbdll.dll" (ByVal Password As String) As Integer
  90. Declare Function RTrimStr Lib "vbdll.dll" (s As String) As String
  91. Declare Function MinInt Lib "vbdll.dll" (i As Integer, j As Integer) As Integer
  92. Declare Function MaxInt Lib "vbdll.dll" (ByVal i As Integer, ByVal j As Integer) As Integer
  93. Declare Function GetDirEntries Lib "vbdll.dll" (s$, DirInfoArray() As Any) As Integer
  94. Sub cmdTestPassword_Click ()
  95. Const MB_OK = 0
  96. Const MB_ICONEXCLAMATION = 48
  97. Dim DgDef, Msg, Response, Title, Rtn As Integer
  98. Dim ExpectedPassword As String
  99.     ExpectedPassword = "MyPassword"
  100.     'Rtn = GetPassword("MyPassword")    'This also works
  101.     Rtn = GetPassword(ExpectedPassword)
  102.     Debug.Print
  103.     Debug.Print "Password Expected string passed to function: "; ExpectedPassword
  104.     Debug.Print "Returned an integer of :"; Rtn
  105.     Debug.Print
  106.     Debug.Print
  107. End Sub
  108. Sub Command1_Click ()
  109. Dim s As String, s1 As String
  110.     s = "This is a variable length string.     "
  111.     s1 = RTrimStr(s)
  112.     Debug.Print "Orig String Length: "; Len(s)
  113.     Debug.Print "Orig String: "; " "; s
  114.     Debug.Print "Trimmed String Length: "; Len(s1)
  115.     Debug.Print "Trimmed String: "; " "; s1
  116. End Sub
  117. Sub Command2_Click ()
  118. Dim i As Integer, j As Integer, k As Integer, s$
  119. ReDim arrFileInfo(1 To 100) As FileInfoStruct
  120.     s$ = "*.*"
  121.     i = GetDirEntries(s$, arrFileInfo())
  122.     Debug.Print ""
  123.     Debug.Print ""
  124.     Debug.Print "i := "; i
  125.     For j = 1 To i
  126.         Debug.Print j; ") "; arrFileInfo(j).Name; "    "; arrFileInfo(j).Size; "    "; arrFileInfo(j).Date; "    "; arrFileInfo(j).Time
  127.     Next j
  128. End Sub
  129. Sub Command3_Click ()
  130. Dim i As Integer, j As Integer, k As Integer
  131.     i = 55
  132.     j = 34
  133.     k = MaxInt(i, j)
  134.     Debug.Print
  135.     Debug.Print "Numbers passed to MinInt function: "; i, j
  136.     Debug.Print "Value returned: "; " "; k
  137.     Debug.Print
  138.     Debug.Print
  139. End Sub
  140.